<script>
function danhmuc(j){

	objName = "danhmuc[" + j + "]";
	var obj=document.getElementById(objName);
//alert(objName);
var objImg = obj.parentNode.getElementsByTagName("img")[0];
objImg.src="/sitemanager/img/expand_uf.gif";

	if(obj.style.display == "none"){
		obj.style.display = "block";
		objImg.src="/sitemanager/img/expand_uf.gif";


	}else{
		obj.style.display = "none";
		objImg.src="/sitemanager/img/expand_f.gif";
	}
}
</script>
<table border="0" cellpadding="0" cellspacing="0">
<?php
	include "../connect.php";
	$sql=mysql_query("select DISTINCT thanhpho from khachhangthanthiet");
	$i=1;
	while($r=mysql_fetch_array($sql))
	{
		$thanhpho=$r["thanhpho"];
		if($thanhpho=="Hồ Chí Minh")
		{							
			echo "<tr><td>
			<div style=\"padding-left:20px;\">
			<table border=0 cellspacing=0 cellpadding=0 >
			<tr><td height=30px width=100%>
			<a onclick=\"danhmuc($i);\"><img src=\"/sitemanager/img/expand_f.gif\" width=9 height=9 /></a>
			<img src=\"/sitemanager/img/file_uf.gif\" width=20 height=20 />
			<a style=\"color:#000000\" onclick='danhmuc($i);' onMouseOver=\"style.color='#0099CC'\" onMouseOut=\"style.color='#000000'\">$thanhpho</a>
			</td></tr>		
			</table>
			</div>";
		}
		else
		{							
			echo "<tr><td>
			<div style=\"padding-left:30px;\">
			<table border=0 cellspacing=0 cellpadding=0 >
			<tr><td height=30px width=100%>			
			<img src=\"/sitemanager/img/file_uf.gif\" width=20 height=20 />
			<a style=\"color:#000000\" onMouseOver=\"style.color='#0099CC'\" onMouseOut=\"style.color='#000000'\" href='?m=khtt&b=khtt-list&tp=$thanhpho'>$thanhpho</a>
			</td></tr>		
			</table>
			</div>";
		}
			$sql5="select DISTINCT quan from khachhangthanthiet where thanhpho='$thanhpho' order by quan";
			$kq5=mysql_query($sql5);
			echo "<table width=195 id='danhmuc[$i]' style='display:none' border=0 cellspacing=0 cellpadding=0>";
			while($r5=mysql_fetch_array($kq5))
			{
				$quan=$r5["quan"];
				$q2=urlencode($r5["quan"]);
			//	for($i=1;$i<=12;$i++)
			//	{
					if($quan==1||$quan==2||$quan==3||$quan==4||$quan==5||$quan==6||$quan==7||$quan==8||$quan==9||$quan==10||$quan==11||$quan==12||$quan=="Tân Bình"||$quan=="Tân Phú"||$quan=="Bình Tân"||$quan=="Bình Thạnh"||$quan=="Thủ Đức"||$quan=="Phú Nhuận"||$quan=="Gò Vấp")	
					$q="Quận: ";
					else $q="Huyện: ";
			//	}
				if($quan=="0")
					echo "";
				else
				echo "
				<tr><td>
				<div style=\"padding-left:40px\">
				<img src=\"/sitemanager/img/file_c.gif\" width=20 height=20 />
				<a href=/sitemanager/?m=khtt&b=khtt-list&q=$q2 style=\"color:#000000\" onMouseOver=\"style.color='#0099CC'\" onMouseOut=\"style.color='#000000'\">$q $quan</a>
				</div></td></tr>";
			}	
			echo "</table>";
			echo "</td></tr>";
			$i++;
			
	}
?>
</table>